package org.monte.previo2;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NavUtils;

public class SeccionListActivity extends SherlockFragmentActivity 
        implements SeccionListFragment.Callbacks {

    private boolean mTwoPane;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seccion_list);

        if (findViewById(R.id.seccion_detail_container) != null) {
            mTwoPane = true;
            ((SeccionListFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.seccion_list))
                    .setActivateOnItemClick(true);
        }
    }

    
    public void onItemSelected(String id,String seccid) {
        if (mTwoPane) {
            Bundle arguments = new Bundle();
            arguments.putString("idApp", id);
            arguments.putString("idSec", id);
            SeccionDetailFragment fragment = new SeccionDetailFragment();
            fragment.setArguments(arguments);
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.seccion_detail_container, fragment)
                    .commit();

        } else {
            Intent detailIntent = new Intent(this, SeccionDetailActivity.class);
            detailIntent.putExtra("idApp", id);
            detailIntent.putExtra("idSec", seccid);
            startActivity(detailIntent);
        }
    }
}
